//
//  01_09_字符串轮转.swift
//  Swift-LeetCode
//
//  Created by 卢悦明 on 2024/3/11.
/*
 https://leetcode.cn/problems/string-rotation-lcci/description/
 字符串轮转。给定两个字符串s1和s2，请编写代码检查s2是否为s1旋转而成（比如，waterbottle是erbottlewat旋转后的字符串）。

 示例1:

  输入：s1 = "waterbottle", s2 = "erbottlewat"
  输出：True
 示例2:

  输入：s1 = "aa", s2 = "aba"
  输出：False
 */

import UIKit

class FlipStringClass {
    
    func QA() {
        print(isFlipedString("waterbottle", "erbottlewat"))
        print(isFlipedString("aa", "aba"))
        print(isFlipedString("", ""))


    }
    
    func isFlipedString(_ s1: String, _ s2: String) -> Bool {
        if s1.count == 0 && s1.count == 0 { return true }
        if s1.count != s2.count  { return false }
        let str = s1 + s1
        return str.contains(s2)
    }
}
